//
//  xlx_platform.h
//  device
//
//  Created by ffly on 2021/3/23.
//

#ifndef __XLX_PLATFORM_H__
#define __XLX_PLATFORM_H__

#include <stdlib.h>

#define TUTU_DEBUG

#define TUTUG(name) g_tutu##name

extern int tutu_show_logger;

//选择当前代码平台，只能放开一行注释
//#define TUTU_CODE_MAC
//#define TUTU_CODE_ASR_SIMWARE
//#define TUTU_CODE_ASR_WTWD
//#define TUTU_CODE_ASR_L342
//#define TUTU_CODE_ASR_SIMCOM
// #define TUTU_CODE_EC618_BSJ
// #define TUTU_CODE_ASR_ML307A        20240412       

#ifndef TUTULOG
#ifdef TUTU_CODE_ASR_WTWD
    #include "ewin_debug.h"

    //log打印wtwd_log_printf
    #define TUTULOG(format,...) \
    if(tutu_show_logger == 1){ewin_trace(format,__VA_ARGS__);}

#elif TUTU_CODE_ASR_L342
    extern void JM_Printf(int chan, const char *fmt, ...);
    extern void JM_Print(int chan, char* sendData, int sendLen);
    extern void JM_PrintLog(const char *fmt,...);

    //chan = 2 输出到ap
    //chan = 3 输出到usb串口
    #define TUTULOG(fmt, args...) \
    if(tutu_show_logger == 1){JM_PrintLog(fmt, ##args);}

#elif TUTU_CODE_ASR_SIMCOM

    extern void tutu_Printf(const char *fmt, ...);
    #define TUTULOG(fmt, args...) tutu_Printf(fmt, ##args);


#elif TUTU_CODE_WIN32
    extern void print_win32_time();
    #define TUTULOG(fmt,...) print_win32_time();printf(fmt, __VA_ARGS__);printf("\n");

#elif TUTU_CODE_EC618_BSJ
    #define TUTULOG(fmt, args...) \
    if(tutu_show_logger == 1){printf(fmt, ##args);printf("\r\n");}

#elif TUTU_CODE_ASR_ML307A     // 中移ml307a项目
    #include "cm_sys.h"
    #define TUTULOG(fmt, args...) \
    if(tutu_show_logger == 1){cm_log_printf(0,"[x]"fmt, ##args);}

#else
    #include "esp_log.h"
    #define TUTULOG(fmt,args...) \
        if(tutu_show_logger == 1){ESP_LOGI("XLX", fmt, ##args);}

    #define TUTU_LOGI(fmt1, fmt2, args...) \
        if(tutu_show_logger == 1){ESP_LOGI(fmt1, fmt2, ##args);}

    #define TUTU_LOGW(fmt1, fmt2, args...) \
        if(tutu_show_logger == 1){ESP_LOGW(fmt1, fmt2, ##args);}        

    #define TUTU_LOGE(fmt1, fmt2, args...) \
        if(tutu_show_logger == 1){ESP_LOGE(fmt1, fmt2, ##args);}        
     // #define TUTULOG(format,...)
#endif

#define TUTULOG_LINE() TUTULOG("%s()---->%d", __FUNCTION__, __LINE__);
#endif

#ifdef TUTU_CODE_ASR_SIMCOM
    #include "simcom_api.h"
    //开辟内存
    #define TUTUAlloc sAPI_Malloc
    //释放内存
    #define TUTUFree sAPI_Free

    #define TUTUSprintf sprintf

    extern void tutu_snprintf(char *buf,int n,const char *fmt,...);
    #define TUTUSnprintf tutu_snprintf

    #define TUTUVsnprintf sAPI_Vsnprintf

#elif TUTU_CODE_ASR_ML307A
    // ml307a 不建议使用C库的
    #include "cm_mem.h"

    //开辟内存
    #define TUTUAlloc cm_malloc
    #define TUTUCalloc cm_calloc
    #define TUTURealloc cm_realloc

    //释放内存
    #define TUTUFree cm_free

    #define TUTUSprintf sprintf
    #define TUTUSnprintf snprintf
    #define TUTUVsnprintf vsnprintf
    
#else
    //开辟内存
    #define TUTUAlloc malloc
    //释放内存
    #define TUTUFree free

    #define TUTUSprintf sprintf
    #define TUTUSnprintf snprintf
    #define TUTUVsnprintf vsnprintf

#endif
#if 1
#define TEST_ICCID          "898604d6102270966696"
#define TEST_IMEI           "866248058840824"
#define TEST_IMSI           "4600856685066960"

#else
#define TEST_ICCID          "898604D6102270220382"
#define TEST_IMEI           "866248062029267"
#define TEST_IMSI           "866248062029267"
#endif

#define  XLX_MAIN_SERVER_READ       "srvRD"
#define  XLX_MAIN_SERVER_WRITE      "srvWR"

#define  XLX_TMS_READ               "tmsRD"
#define  XLX_TMS_WRITE              "tmsWR"


#endif /* xlx_platform_h */
